<template>
  <div>
    <el-card style="margin-bottom: 20px">
      <el-breadcrumb separator-class="el-icon-arrow-right" style="margin: 20px">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item to="">留言板管理</el-breadcrumb-item>
        <el-breadcrumb-item to="">留言板列表</el-breadcrumb-item>
      </el-breadcrumb>
        <el-row :gutter="20">
        <el-col :span="8">
          <el-input placeholder="请输入内容">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
    </el-card>
    <el-card style="margin-bottom: 20px">
      <el-table :data="tableData" height="450px" stripe>
        <el-table-column label="创建时间" prop="createTime"></el-table-column>
        <el-table-column label="留言人id" prop="userId"></el-table-column>
        <el-table-column label="用户名" prop="username"></el-table-column>
        <el-table-column
          label="留言内容"
          prop="content"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column label="留言图片" prop="picture">
          <template slot-scope="scope">
            <img
              width="100px"
              class="fupin_img"
              :src="scope.row.picture"
              alt=""
            />
          </template>
        </el-table-column>
        <el-table-column
          label="回复内容"
          prop="reply"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column label="回复图片" prop="replyPicture">
          <template slot-scope="scope">
            <img
              width="100px"
              class="fupin_img"
              :src="scope.row.replyPicture"
             
            />
          </template>
        </el-table-column>
        <el-table-column label="操作" width="160" align="center">
          <template slot-scope="scope">
           
            <el-button
              type="danger"
              size="mini"
              @click="del(scope.$index, scope.row.id)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <div style="margin: 20px">
        <el-pagination
          layout="prev, pager, next"
          :total="total"
          background
          :page-size="pageSize"
          @current-change="current"
        >
        </el-pagination>
        <!-- 留言板编辑 -->
        
      </div>
    </el-card>
  </div>
</template>
<script>
export default {
  data() {
    return {
      tableData: [],
      total:3,
      pageNum:1,
      pageSize:3,
   

     
    };
  },
  methods: {
   async getList(pageNum, pageSize) {
      // let {data:res} = await this.$axios.get('data/fupin.json');
      // // window.console.log(res.data.list);
      // this.tableData=res.data.list
      let { data: res } = await this.$axios.get("/msgboard/getlist", {
        params: {
          pageNum,
          pageSize,
        },
      });
      
      this.total = res.data.total;
      this.tableData = res.data.list;
    },
    current(e) {
      // window.console.log(e);
       this.pageNum=e;
       this.getList(e, this.pageSize);
    },
   
   async del(index, id) {
      // window.console.log(id);
       let { data: res } = await this.$axios.get("/msgboard/delete", {
        params: {
          id: id,
        },
      });
      if (res.code != 200) return this.$message.error(res.code);
      this.getList(this.pageNum,this.pageSize);
    },
  },
  created() {
    this.getList(this.pageNum,this.pageSize);
  },
};
</script>
<style scoped>
</style>